<form id="info-form" method="post">
    <table>
        <input type="hidden" name="id" value="@if(!empty($info)) {{$info['id']}} @endif"/>
        <tr>
            <td>商品名称:</td>
            <td><input class="easyui-textbox" type="text" name="name" data-options="required:true"
                       value="@if(!empty($info)){{$info['goods_name']}}@endif"/></td>
        </tr>
        <tr>
            <td>商品分类:</td>
            <td>
                <input id="category_id" name="category_id" value="@if(!empty($info)){{$info['category_name']}}@endif" data-options="required:true"/>
            </td>
        </tr>
        <tr>
            <td>所属品牌:</td>
            <td>
                <input id="brand_id"  name="brand_id" value="@if(!empty($info)){{$info['brand_name']}}@endif" data-options="required:true"/>
            </td>
        </tr>
        <tr>
            <td>标签:</td>
            <td>
                <input id="label_ids"  name="label_ids" value="@if(!empty($info)){{$info['label_names']}}@endif" style="width: 100%" data-options="required:true"/>
            </td>
        </tr>

        <tr>
            <td>商品规格:</td>
            <td><input class="easyui-textbox" type="text" name="goods_spec" data-options="required:true"
                       value="@if(!empty($info)){{$info['goods_spec']}}@endif"/></td>
        </tr>
        <tr>
            <td>制造商链接</td>
            <td>
                <input id="manufacturers_url" name="manufacturers_url" class="easyui-textbox" data-options="required:true,validType:'url'"
                       @if(!empty($info)) value="{{$info['manufacturers_url']}}" @else value="http://" @endif  style="width: 70%" />
            </td>
        </tr>
        <tr>
            <td>商品主图:</td>
            <td>
                <input class="easyui-filebox" style="width:300px" data-options='onChange:change_photo' id="file_upload"
                       name="goods_image"/>
                <div id="Imgdiv"><img id="Img" width="80" height="80"
                                      src="@if(!empty($info)){{env('RESOURCE_URL').$info['goods_image']}}@endif"></div>
            </td>
        </tr>
        <tr>
            <td>商品售价:</td>
            <td><input class="easyui-textbox" type="text" name="goods_price" data-options="required:true"
                       value="@if(!empty($info)){{$info['goods_price']}}@endif"/></td>
        </tr>
        <tr>
            <td>商品状态:</td>
            <td>
                 <span class="radioSpan">
                <input type="radio"  name="goods_state" value="1" @if(!empty($info) && $info['goods_state']===1) checked
                        @endif/>上架
                     <input type="radio"   name="goods_state" value="0" @if(!empty($info) && $info['goods_state']===0) checked
                             @endif/>下架
            </span>
            </td>
        </tr>
    </table>
</form>

<script>
    $(function () {
        var token = $('meta[name="csrf-token"]').attr('content');
        var category_id  = $('#category_id');
        var brand_id  = $('#brand_id');
        var label_ids  = $('#label_ids');
        category_id.combotree({
            url:'/product/cate/tree',
            queryParams: {
                _token: token
            }
        });
        brand_id.combobox({
            url:'/product/brand/tree',
            queryParams: {
                _token: token
            },
            valueField:'id',
            textField:'name',
            editable:false
        });
        label_ids.combobox({
            url:'/product/label/tree',
            queryParams: {
                _token: token
            },
            valueField:'id',
            textField:'name',
            multiple:true,
            editable:false
        })

        @if(!empty($info))
        category_id.combotree('setValue',{id:{{$info['category_id']}}, text:'{{$info['category_name']}}'});
        brand_id.combobox('setValue',{{$info['brand_id']}});
        brand_id.combobox('setText','{{$info['brand_name']}}');
        label_ids.combobox('setValues',[{{$info['label_ids']}}]);
        label_ids.combobox('setText','{{$info['label_names']}}');
        @endif
    })
</script>
